/*
 * jQuery dataForAjax plug-in 1.1
 *
 * Copyright (c) 2010 cainiao 2010-05-23
 *
 */
jQuery.fn.dataForAjax = function(){
	var json;
	var id = "#" + this.attr("id");
	var data = $(id).serialize();
	data = decodeURIComponent(data, true); 
	
	json = '{';
	var params = data.split("&");
	// update by cainiao 2011-10-05
	// for(var i in params){
	for(var i = 0; i < params.length; i++){
		var param = params[i].split("=");
		var key = param[0];
		var val = param[1];
		if(param.length == 2){
			if(i != params.length - 1){
				json += '"'+ key +'":"' + val +'",';
			}else{
				json += '"'+ key +'":"' + val +'"';
			}
		}
	}
	json += '}';
	json = eval('('+json+')');
	
	return {data: data, json: json};
};